﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using IDAL;
using DBUtility;
using System.Collections;
using System.Collections.Generic;

namespace SQLServerDAL
{
   public   class RecommendLevelSetMe
    {

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.RecommendLevelSet GetModel(int  RecommendId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from [RecommendLevelSet] ");
            strSql.Append(" where [RecommendManLevel]=@RecommendManLevel");
            SqlParameter[] parameters = {
                    new SqlParameter("@RecommendManLevel", SqlDbType.Int)};
            parameters[0].Value = RecommendId;
            DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow r = ds.Tables[0].Rows[0];
                return GetModel(r);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 由一行数据得到一个实体
        /// </summary>
        private Model.RecommendLevelSet GetModel(DataRow r)
        {
            Model.RecommendLevelSet model = new Model.RecommendLevelSet();
            model.RecommendId = SqlHelper.GetString(r["RecommendId"]);
            model.RecommendManLevel = SqlHelper.GetInt(r["RecommendManLevel"]);
            model.RecommendInergalSeparate = SqlHelper.GetDecimal(r["RecommendInergalSeparate"]);
            model.RecommendCostSeparate = SqlHelper.GetDecimal(r["RecommendCostSeparate"]);
            model.Attribute1 = SqlHelper.GetString(r["Attribute1"]);
            model.Attribute2 = SqlHelper.GetString(r["Attribute2"]);
            model.Attribute3 = SqlHelper.GetString(r["Attribute3"]);
            model.Attribute4 = SqlHelper.GetString(r["Attribute4"]);
            model.Attribute5 = SqlHelper.GetInt(r["Attribute5"]);
            model.Attribute6 = SqlHelper.GetInt(r["Attribute6"]);
            model.Attribute7 = SqlHelper.GetDecimal(r["Attribute7"]);
            model.Attribute8 = SqlHelper.GetDecimal(r["Attribute8"]);
            return model;
        }


    }
}
